package com.sr.service.impl;

import com.sr.ibase.IBaseService;
import com.sr.ibase.impl.BaseServiceImpl;
import com.sr.pojo.WNavBar;
import com.sr.service.INavBarService;
import com.sr.vo.req.NavBarReqVo;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @author xiaochi
 * @date 2022/4/30 13:15
 * @desc NavBarServiceImpl
 */
@Service
public class NavBarServiceImpl extends BaseServiceImpl<WNavBar> implements INavBarService {

    /**
     * 判断名称是否存在
     * @param reqVo
     * @return
     */
    public boolean hasExistsByName(NavBarReqVo reqVo){
        IBaseService.Criteria<WNavBar> criteria = this.createCriteria(WNavBar.class);
        criteria.andEqualTo(WNavBar::getName,reqVo.getName())
                .andNotEqualTo(WNavBar::getId,!StringUtils.isEmpty(reqVo.getId()),reqVo.getId());
        return this.count(criteria) > 0;
    }
}
